<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Block</title>
</head>

<body>
<?php
include("../connection/connection.php");
include("reportFunctions.php");
$distId=$_REQUEST['distId'];
//$blockId=4308;
$sqlReport="SELECT block_id as block_id,`block_name` FROM `tbl_lookup_location` where `district_id` = ".$distId." group by `block_id`";
//$sqlReport = "SELECT main.block_id as block_id,loc.`block_name` FROM `tbl_lookup_location` loc,tbl_dtls_q1_main main where main.`district_id` = ".$distId." and main.block_id=loc.block_id group by main.`block_id`";
//echo $sqlReport;
$queryReport = mysql_query($sqlReport);
?>

<table border="0" width="608" cellspacing="0" cellpadding="0">
	<tr>
		<td height="26" colspan="3" bgcolor="#E9E9E9">
		<p align="center"><span style="font-size: 9pt; font-weight: 700">
	  <font face="Verdana" color="#224568">Block wise Time taken for redressal of Complaints (as per PHED)</font></span></td>
	</tr>
	<tr>
	  <td height="26" colspan="3" bgcolor="#E9E9E9"><div align="center"><font face="Verdana" style="font-size: 9pt; font-weight: 700" color="#224568">Table 13 </font></div></td>
  </tr>
	<tr>
		<td height="56" colspan="3" bgcolor="#E9E9E9">
		<table border="1" width="610" cellspacing="0" cellpadding="0" height="55" bgcolor="#C5D8EB">
			<tr>
				<td width="109" height="53" align="center">
				<p align="center"><font face="Verdana" style="font-size: 8.5pt">
			  Block</font></td>
				<td width="167" align="center">
				<font face="Verdana" style="font-size: 8.5pt">Time Taken for Complaint Redressal</font></td>
				<td width="175" align="center">
				  <p align="center">
			  <font style="font-size: 8.5pt" face="Verdana">No. of Complaints (per year)</font></td>
				<td width="149" align="center">
				  <font style="font-size: 8.5pt" face="Verdana">Percentage of Complaints Attended to</font></td>
			</tr>
		</table>		</td>
	</tr>
	<tr>
		<td colspan="3">
		<table border="1" width="611" cellspacing="0" cellpadding="0" height="164" bordercolor="#C5D8EB" style="border: 1px solid #BBD1E8" bgcolor="#F9F9F9">
		<?php while($rowReport = mysql_fetch_array($queryReport)) {
		 $blockId = $rowReport['block_id'];
			$supplyDuration1=getTimeTaken($distId,$blockId,0,1);
			 $supplyDuration2=getTimeTaken($distId,$blockId,1,2);
 		$supplyDuration3=getTimeTaken($distId,$blockId,2,3);
 		$supplyDuration4=getTimeTaken($distId,$blockId,3,"");
 		$supplyDuration5=getTimeTaken($distId,$blockId,"","null");
		
		$totalDuration=$supplyDuration1+$supplyDuration2+$supplyDuration3+$supplyDuration4+$supplyDuration5;//getTimeTaken($distId,$blockId,"","");
		//getSupplyDuration($distId,"","");
		?>
			<tr>
				<td width="110" rowspan="5" align="center" valign="top"><font face="Verdana" style="font-size: 8.5pt"><?php echo $rowReport['block_name'];?></font></td>
				<td width="166" align="center"><font face="Verdana" style="font-size: 8.5pt">&lt; 1 day (24 hrs)</font></td>
				<td width="173" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php echo $supplyDuration1;?></font></td>
				<td width="152" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php 
				if($totalDuration==0)
				{
					echo "0.00";
				}
				else
				{
					echo number_format($supplyDuration1*100/$totalDuration,2,'.','');}?></font></td>
			</tr>
			<tr>
				<td width="166" align="center"><font face="Verdana" style="font-size: 8.5pt">1 to 2 days (24 to 48 hrs)</font></td>
				<td width="173" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php echo $supplyDuration2;?></font></td>
				<td width="152" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php 
				if($totalDuration==0)
				{
					echo "0.00";
				}
				else
				{
				echo number_format($supplyDuration2*100/$totalDuration,2,'.','');}?></font></td>
			</tr>
			<tr>
				<td width="166" align="center"><font face="Verdana" style="font-size: 8.5pt">2 to 3 days (48 to 72 hrs)</font></td>
				<td width="173" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php echo $supplyDuration3;?></font></td>
				<td width="152" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php 
				if($totalDuration==0)
				{
					echo "0.00";
				}
				else
				{
				echo number_format($supplyDuration3*100/$totalDuration,2,'.','');}?></font></td>
			</tr>
			<tr>
				<td width="166" align="center"><font face="Verdana" style="font-size: 8.5pt">&gt; 3 days (&gt; 72 hrs)</font></td>
				<td width="173" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php echo $supplyDuration4 ;?></font></td>
				<td width="152" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php 
				if($totalDuration==0)
				{
					echo "0.00";
				}
				else
				{
				echo number_format($supplyDuration4*100/$totalDuration,2,'.','');}?></font></td>
			</tr>
			<tr>
				<td width="166" align="center"><font face="Verdana" style="font-size: 8.5pt">Not Provided</font></td>
				<td width="173" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php echo $supplyDuration5;?></font></td>
				<td width="152" align="center"><font face="Verdana" style="font-size: 8.5pt"><?php 
				if($totalDuration==0)
				{
					echo "0.00";
				}
				else
				{
				echo number_format($supplyDuration5*100/$totalDuration,2,'.','');}?></font></td>
			</tr>
			<tr>
				<td height="25" colspan="2" align="center" bgcolor="#E9E9E9">
				<font style="font-size: 8.5pt" face="Verdana"><font style="font-size: 8.5pt" face="Verdana">Total</font></td>
				<td width="173" align="center" bgcolor="#E9E9E9"><font face="Verdana" style="font-size: 8.5pt"><?php echo $totalDuration; ?></font></td>
				<td width="152" align="center" bgcolor="#E9E9E9"><font face="Verdana" style="font-size: 8.5pt"><?php //echo number_format($totalDuration*100/$grantTotalDuration,2);?></font></td>
			</tr>
			<?php 
			$grantTotalDuration+=$totalDuration;
			}
			
			?>
		
  <tr>
				<td colspan="2" align="center" bgcolor="#E9E9E9">
				<font style="font-size: 8.5pt" face="Verdana"><font style="font-size: 8.5pt" face="Verdana">Grand Total</font></td>
				<td width="173" align="center" bgcolor="#E9E9E9"><font face="Verdana" style="font-size: 8.5pt"><?php echo $grantTotalDuration;?></font></td>
				
				<td width="152" align="center" bgcolor="#E9E9E9"><font face="Verdana" style="font-size: 8.5pt">&nbsp;</font></td>
				
 
				
  </tr>
		
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>


</body>

</html>